package com.siashan.toolkit.captcha.google;

import com.siashan.toolkit.captcha.cache.CaptchaCacheAutoConfiguration;
import com.siashan.toolkit.captcha.cache.CaptchaCacheTemplate;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * 验证码缓存自动配置器
 *
 * @author siashan
 * @since v1.0.5
 */
@Configuration
@ConditionalOnClass(CaptchaCacheTemplate.class)
@AutoConfigureAfter(CaptchaCacheAutoConfiguration.class)
@Import(CaptchaCacheAutoConfiguration.class)
public class GoogleCaptchaAutoConfiguration {



    @SuppressWarnings("rawtypes")
    @Bean
    @ConditionalOnMissingBean
    public GoogleCaptchaTemplate googleCaptchaTemplate(CaptchaCacheTemplate captchaCacheTemplate) {
        GoogleCaptchaTemplate googleCaptchaTemplate = new GoogleCaptchaTemplate(captchaCacheTemplate);
        return googleCaptchaTemplate;
    }
}
